package com.mxx.common.core;

public final class Failure {

    public static Failure SUCCESSFUL = new Failure(false, null, null);

    private boolean error;

    private String errCode;

    private String errMessage;

    public Failure(boolean error, String errCode, String errMessage) {
        this.error = error;
        this.errCode = errCode;
        this.errMessage = errMessage;
    }

    public static Failure instance(String errCode, String errMessage) {
        Failure failure = new Failure(true, errCode, errMessage);
        return failure;
    }

    public static Failure instance(String errMessage) {
        Failure failure = new Failure(true, "EXCEPTION", errMessage);
        return failure;
    }

    public String getErrCode() {
        return errCode;
    }

    public String getErrMessage() {
        return errMessage;
    }

    public boolean isError() {
        return error;
    }
}
